/**
 * Created by yyj on 2015/9/15.
 */
//点击跳转
function jump(url){
    location.href=url;
}
//另外添加内容之后的删除
function delbtn(btn){
    $(btn).parents().parents('li').hide();
}

function iFrameHeight() {
    var ifm = document.getElementById("iframepage");
    var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;
    if (ifm != null && subWeb != null) {
        ifm.height = subWeb.body.scrollHeight;
        ifm.width = subWeb.body.scrollWidth;
    }
}
//iframe切换
function changeiframe(target){
    $('#platform_content').attr('src',$(target).attr('name'));
}

//柱形图
function echart_detail(divId){
    require.config({
        paths: {
            echarts: '../../common/plugins/echarts/'
        }
    });
    require(
        [
            'echarts',
            'echarts/chart/line',   // 按需加载所需图表，如需动态类型切换功能，别忘了同时加载相应图表
            'echarts/chart/bar'
        ],
        function (ec) {
            var myChart = ec.init(document.getElementById(divId),'macarons');
            var option = {

                tooltip: {
                    trigger: 'axis',
                    //backgroundColor: 'rgba(0,0,0,0.5)',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'bar',         // 默认为直线，可选为：'line' | 'shadow'
                        lineStyle: {          // 直线指示器样式设置
                            color: 'red',//坐标轴指示器，默认type为line，可选为：'line' | 'cross' | 'shadow' | 'none'(无)，
                            type: 'dashed'
                        }
                    }
                },
                grid:{
                    x:30,
                    y:30,
                    x2:60,
                    y2:30
                },
                xAxis : [
                    {
                        type : 'category',
                        axisLabel: {
                            rotate: 25
                        },
                        data : [' ',' ',' ',' ',' ']
                    }
                ],
                yAxis : [
                    {
                        type : 'value'
                    }
                ],
                series : [
                    {
                        name:'事件次数',
                        type:'bar',
                        barMaxWidth: 25,//设置系统最大宽度，不设置时自动适应
                        itemStyle: {
                            normal: {
                                label: { show: true },
                                color: function (params) {
                                    var colorList = [
                                        '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B', '#FE8463',
                                        '#D7504B', '#C6E579', '#F4E001', '#F0805A', '#26C0C0', '#9BCA63'
                                    ];
                                    if (params.dataIndex > 12) {
                                        return colorList[(params.dataIndex - 12) % 12];
                                    } else {
                                        return colorList[params.dataIndex];
                                    }
                                }
                            }
                        },
                        data:[3, 13, 17, 29, 5]

                    }
                ]
            };
            myChart.setOption(option);
        });
}

//更换图片
function setImg(imgurl){
    var Img=$(imgurl).attr('src');
    $(imgurl).parents('.imgbox').siblings('.imgsrc').attr('src',Img);
    $(imgurl).parents('.imgbox').hide();
    $(imgurl).parents('.imgbox').siblings('.img01').attr('iconFileId',iconFileId);
}
//更换图片
function setImg(imgurl){
    var Img=$(imgurl).attr('src');
    var iconFileId=$(imgurl).attr("iconFileId");
    $('.imgsrc').attr('src',Img);
    $('.imgsrc').attr('iconFileId',iconFileId);
    $(imgurl).parents('.imgbox').hide();
}
//修改配置项中其他属性点击内容跳转

function editJump(num){
    parent.layer.open({
    	extend:['skin/layer_iframe.css'],
        skin:'layer-ext-skin-layer_iframe.css',
        type:2,
        title:'修改属性组属性',
        area:['800px','400px'],

        content:num,
        maxmin: true,
        shadeClose: true

    });
}
$(function(){
	//给数组添加方法
	//获取数组元素索引位置
	Array.prototype.indexOf = function(val) {              
	    for (var i = 0; i < this.length; i++) {  
	        if (this[i] == val) return i;  
	    }  
	    return -1;  
	};
	//删除指定元素
	Array.prototype.remove = function(val) {  
	    var index = this.indexOf(val);  
	    if (index > -1) {  
	        this.splice(index, 1);  
	    }  
	};
//*/页面高度
	var htmlHeight=document.documentElement.clientHeight;
    //alert(htmlHeight);
	
	if($('.content_detail').height()<=(htmlHeight-55)){
        $('.content_detail').css('minHeight',htmlHeight-55);
        $('.content_detail.nocontent').css('minHeight',htmlHeight-65);

	}else{
		$('.content_detail').css({
			height:'auto',
			overflow:'hidden'
		})
	}
	
//页面高度
	$('.content_l').height(htmlHeight-65);
	
	if($('.content_r').height()<=(htmlHeight-65)){
		$('.content_r').css('minHeight',htmlHeight-65)
	}else{
		$('.content_r').css({
			height:'auto',
			overflow:'hidden'
		})
	}
});

/**
 * 判断对象是否为数组
 * @param obj 参数对象
 * @returns Boolean true是数组，false不是数组
 */
function isArray(obj) {  
	return Object.prototype.toString.call(obj) === '[object Array]';   
}

(function($){
	/**
	 * 把光标定位到文本最后
	 */
    $.fn.textFocus=function(v){
        var range,len,v=v===undefined?0:parseInt(v);
        this.each(function(){
            if($.browser.msie){
                range=this.createTextRange();
                v===0?range.collapse(false):range.move("character",v);
                range.select();
            }else{
                len=this.value.length;
                v===0?this.setSelectionRange(len,len):this.setSelectionRange(v,v);
            }
            this.focus();
        });
        return this;
    }
})(jQuery);
